//
//  RegisteringCell.m
//  HandheldHospital
//
//  Created by zhangchao on 16/3/8.
//  Copyright © 2016年 zhangchao. All rights reserved.
//

#import "RegisteringCell.h"
#import <Masonry.h>

#define kWidth self.contentView.frame.size.width
#define kHeight self.contentView.frame.size.height
#define kLabelHeight 30

@interface RegisteringCell ()

@end

@implementation RegisteringCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self addViews];
    }
    return self;
}

//页面布局
- (void)addViews
{
    //订单状态
    [self addTypeLabel];
    //就诊人姓名
    [self addNameLabel];
    //医院
    [self addHospitalLabel];
    //科类
    [self addKeLeiLabel];
    //时间
    [self addDateLabel];
}
//订单状态
- (void)addTypeLabel
{
    UILabel *label = [[UILabel alloc] init];
    label.text = @"订单状态:";
    label.textAlignment = NSTextAlignmentLeft;
    label.textColor = [UIColor grayColor];
    [self.contentView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.left.equalTo(self.contentView).offset(10);
        make.size.mas_equalTo(CGSizeMake(kWidth * 0.35, kLabelHeight));
    }];
    
    self.registeringType = [[UILabel alloc] init];
    self.registeringType.textAlignment = NSTextAlignmentRight;
    self.registeringType.textColor = [UIColor blueColor];
    [self.contentView addSubview:self.registeringType];
    [self.registeringType mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.right.equalTo(self.contentView).offset(-20);
        make.size.mas_equalTo(CGSizeMake(kWidth * 0.3, kLabelHeight));
    }];

}
//就诊人姓名
- (void)addNameLabel
{
    UILabel *label = [[UILabel alloc] init];
    label.text = @"就诊人姓名:";
    [self.contentView addSubview:label];
    label.textColor = [UIColor grayColor];
    label.textAlignment = NSTextAlignmentLeft;
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10 + kLabelHeight);
        make.left.equalTo(self.contentView).offset(10);
        make.size.mas_equalTo(CGSizeMake(kWidth * 0.35, kLabelHeight));
    }];
    self.nameLabel = [[UILabel alloc] init];
    self.nameLabel.textAlignment = NSTextAlignmentLeft;
    [self.contentView addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10 + kLabelHeight);
        make.left.equalTo(self.contentView).offset((kWidth * 0.35));
        make.size.mas_equalTo(CGSizeMake(kWidth * 0.5, kLabelHeight));
    }];
}
//医院
- (void)addHospitalLabel
{
    UILabel *label = [[UILabel alloc] init];
    label.text = @"就诊医院:";
    label.textAlignment = NSTextAlignmentLeft;
    label.textColor = [UIColor grayColor];
    [self.contentView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10 + 2 * kLabelHeight);
        make.left.equalTo(self.contentView).offset(10);
        make.size.mas_equalTo(CGSizeMake(kWidth * 0.35, kLabelHeight));
    }];
    
    self.hospitalname = [[UILabel alloc] init];
    self.hospitalname.textAlignment = NSTextAlignmentLeft;
    [self.contentView addSubview:self.hospitalname];
    [self.hospitalname mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10 + 2 * kLabelHeight);
        make.left.equalTo(self.contentView).offset((kWidth * 0.35));
        make.size.mas_equalTo(CGSizeMake(kWidth * 0.5, kLabelHeight));
    }];
}
//科类
- (void)addKeLeiLabel
{
    UILabel *label = [[UILabel alloc] init];
    label.text = @"所挂科类:";
    label.textAlignment = NSTextAlignmentLeft;
    label.textColor = [UIColor grayColor];
    [self.contentView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10 + 3 * kLabelHeight);
        make.left.equalTo(self.contentView).offset(10);
        make.size.mas_equalTo(CGSizeMake(kWidth * 0.35, kLabelHeight));
    }];
    
    
    self.keLei = [[UILabel alloc] init];
    self.keLei.textAlignment = NSTextAlignmentLeft;
    [self.contentView addSubview:self.keLei];
    [self.keLei mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10 + 3 * kLabelHeight);
        make.left.equalTo(self.contentView).offset((kWidth * 0.35));
        make.size.mas_equalTo(CGSizeMake(kWidth * 0.5, kLabelHeight));
    }];
}
//时间
- (void)addDateLabel
{
    UILabel *label = [[UILabel alloc] init];
    label.text = @"就诊日期:";
    label.textAlignment = NSTextAlignmentLeft;
    label.textColor = [UIColor grayColor];
    [self.contentView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10 + 4 * kLabelHeight);
        make.left.equalTo(self.contentView).offset(10);
        make.size.mas_equalTo(CGSizeMake(kWidth * 0.35, kLabelHeight));
    }];
    
    self.registerDate = [[UILabel alloc] init];
    self.registerDate.textAlignment = NSTextAlignmentLeft;
    [self.contentView addSubview:self.registerDate];
    [self.registerDate mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10 + 4 * kLabelHeight);
        make.left.equalTo(self.contentView).offset((kWidth * 0.35));
        make.size.mas_equalTo(CGSizeMake(kWidth * 0.5, kLabelHeight));
    }];
}

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *ID = @"Cell";
    RegisteringCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[RegisteringCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
